<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

$tablename = "MY_TABLE";
$data = array(
    "field1" => 41324,
    "field2" => "value2",
    "field3" => "value3",
);

echo insert_table($tablename, $data);

function insert_table($tablename, $data) {
    $fields = array_keys($data);
    $values = array_values($data);
    
    $sql = "INSERT INTO $tablename (" .implode(', ', $fields). ") "
            . " VALUES ('" .implode("', '", $values). "')";
    
    return $sql;
}
?>

